package sms

import (
	"sync"

	"github.com/runningwater/gohub/pkg/config"
)

// Message 短信消息结构体
type Message struct {
	Template string
	Data     map[string]string

	Content string
}

// SMS 发送短信的操作类
type SMS struct {
	Driver Driver
}

var once sync.Once

var internalSMS *SMS

func NewSMS() *SMS {
	once.Do(func() {
		internalSMS = &SMS{
			Driver: &AliyunDriver{},
		}
	})
	return internalSMS
}

// Send 发送短信
func (s *SMS) Send(phone string, message Message) bool {
	// 调用短信驱动的发送方法
	return s.Driver.Send(phone, message, config.GetStringMapString("sms.aliyun"))
}
